package com.gonetbar.sys.vo;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * 
 * @Description: 
 * 
 * @author weisd Email:xiyangdewuse@163.com
 * @date 2011-1-9 下午10:03:12
 * @version v1.0
 */
public class UserInfoValidator implements Validator {

	public boolean supports(Class<?> clazz) {
		return false;
	}

	public void validate(Object target, Errors errors) {
		UserInfo user = (UserInfo)target;		
		
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userId", "errors.required",new Object[]{"恩1"}, "Required field");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userName", "errors.required",new Object[]{"恩2"}, "Required field");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userPass", "errors.required",new Object[]{"恩3"}, "Required field");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userPassBak", "errors.required",new Object[]{"恩4"}, "Required field");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "userEmail", "errors.required",new Object[]{"恩5"}, "Required field");
//		 
//		if ( ! errors.hasFieldErrors("price")) {
//			if (car.getPrice().intValue() == 0)
//				errors.rejectValue("price", "not_zero", "Can't be free!");
//		}
		
	}
	
	public void validate(Object target, Errors errors,String type) {

	}

}
